package com.future.mapper;

import com.future.entity.Pet;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <P>
 *
 * </p>
 *
 * @author yinhao
 * @version 1.0
 * @since 2024/9/11 16:33
 */
public interface PetMapperAnnotation {

    @Select("select * from mybatis_pet where id = #{id}")
    @Results({
            @Result(property = "id", column = "id",id = true),
            @Result(property = "nickname", column = "nickname"),
            @Result(property = "user", column = "user_id", one = @One(select = "com.future.mapper.UserMapper.queryUserSelfById"))
    })
    Pet queryPetById(Integer id);

    @Select("select * from mybatis_pet where user_id = #{userId}")
    List<Pet> queryPetByUserId(Integer userId);
}
